/**
 * creation: 3-dec-2007
 */
package org.jfonia.musicxml;

import java.util.ArrayList;
import java.util.List;

import org.jfonia.musicxml.model.ScorePartwise;
import org.jfonia.util.JFoniaException;

/**
 * @author Wijnand
 *
 */
public class Score
{
	private ScorePartwise xmlScore = null;
	
	private int divisions = -1;	// "not set"
	
	private List<Part> partList = new ArrayList<Part>();
	
	public Score(ScorePartwise xmlScore) throws JFoniaException
	{
		this.xmlScore = xmlScore;
	
		for (String key: xmlScore.getPartMap().keySet())
		{
			Part part = new Part(xmlScore.getPartMap().get(key));
			partList.add(part);
			int div = part.getDivisions();
			if (divisions == -1)
				divisions = div;
			else if (divisions != div)
				throw new RuntimeException("All parts must have same 'divisions'");
				
		}		
	}
	
	public int getDivisions()
	{
		return divisions;
	}


	public void setDivisions(int divisions)
	{
		this.divisions = divisions;
	}


	public List<Part> getPartList()
	{
		return partList;
	}


	public void setPartList(List<Part> partList)
	{
		this.partList = partList;
	}


	public ScorePartwise getXmlScore()
	{
		return xmlScore;
	}


	public void setXmlScore(ScorePartwise xmlScore)
	{
		this.xmlScore = xmlScore;
	}



}
